//
//  TravelFirstTableViewCell.m
//  NineGroupProject
//
//  Created by dllo on 15/12/25.
//  Copyright © 2015年 lushan. All rights reserved.
//

#import "TravelFirstTableViewCell.h"
#import "Masonry.h"
#import "LabelTableViewCell.h"
#import "TravelPhotoViewController.h"
@implementation TravelFirstTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews{
    self.leftV = [[UIView alloc] init];
    [self.contentView addSubview:self.leftV];
    [self.leftV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.top.mas_equalTo(0);
        make.width.mas_equalTo((WIDTH - 1 * WID) / 2);
        make.height.mas_equalTo(50 * HEI);
        
    }];
    
    UIImageView *photoV = [[UIImageView alloc] init];
    [self.leftV addSubview:photoV];
    [photoV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(((WIDTH - 1 * WID) / 2 - 50 * WID) / 2);
        make.top.mas_equalTo(0 * HEI);
        make.width.and.height.mas_equalTo(30 * WID);
        
    }];
    photoV.image = [UIImage imageNamed:@"iconfont-icon.png"];
    photoV.userInteractionEnabled = YES;
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    photoV.tag = 1000;
    [photoV addGestureRecognizer:tap];
    
    UILabel *photoLabel = [[UILabel alloc] init];
    [self.leftV addSubview:photoLabel];
    [photoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(photoV.mas_left).offset(3);
        make.top.equalTo(photoV.mas_bottom);
        make.width.equalTo(photoV.mas_width);
        make.height.mas_equalTo(20 * HEI);
        
    }];
    photoLabel.text = @"照片";
    photoLabel.font = [UIFont systemFontOfSize:12];
    
    self.lineV = [[UIImageView alloc] init];
    [self.contentView addSubview:self.lineV];
    self.lineV.backgroundColor = [UIColor grayColor];
    [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftV.mas_right);
        make.top.equalTo(self.leftV.mas_top).offset(10);
        make.width.mas_equalTo(1);
        make.height.mas_equalTo(30);
        
    }];
    
    self.rightV = [[UIView alloc] init];
    [self.contentView addSubview:self.rightV];
    [self.rightV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.lineV.mas_right);
        make.width.mas_equalTo((WIDTH - 1 * WID) / 2);
        make.height.mas_equalTo(50 * HEI);
        
    }];
    
    UIImageView *diaryV = [[UIImageView alloc] init];
    [self.rightV addSubview:diaryV];
    [diaryV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(((WIDTH - 1 * WID) / 2 - 50 * WID) / 2);
        make.top.mas_equalTo(0 * HEI);
        make.width.and.height.mas_equalTo(30 * WID);
        
    }];
    diaryV.image = [UIImage imageNamed:@"iconfont-youji-2.png"];
    
    UILabel *diaryLabel = [[UILabel alloc] init];
    [self.rightV addSubview:diaryLabel];
    [diaryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(diaryV.mas_left).offset(3);
        make.top.equalTo(diaryV.mas_bottom);
        make.width.equalTo(diaryV.mas_width);
        make.height.mas_equalTo(20 * HEI);
        
    }];
    diaryLabel.text = @"游记";
    diaryLabel.font = [UIFont systemFontOfSize:12];

    self.inV = [[UILabel alloc] initWithFrame:CGRectMake(10 * WID, 55 * HEI, WIDTH - 10 * WID * 2, 200)];
    [self.contentView addSubview:self.inV];
    
}
-(void)setDescriptions:(NSString *)descriptions{
    self.inV.text = descriptions;
    self.inV.numberOfLines = 0;

    CGFloat height = [LabelTableViewCell heightForContent:descriptions];
    CGRect tempFrame = self.inV.frame;
    tempFrame.size.height = height;
    self.inV.frame = tempFrame;


}
-(void) setDiaryModel:(DiaryModel *)diaryModel{
    _diaryModel = diaryModel;
}

-(void)tapAction:(UITapGestureRecognizer *)tap
{
    [self.cellDelegate pushToViewControllerTag:tap.view.tag DiaryModel:self.diaryModel];
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
